package com.intct.redis;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.HashMap;
import java.util.Map;

/**
 * @author gufg
 * @since 2025-08-12 14:31
 */
public class JedisTest01 {
    public static void main(String[] args) {
//        Jedis jedis = new Jedis("cdh-node", 16379);
//        jedis.auth("Test_090110");
//        System.out.println(jedis.ping());

        GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        poolConfig.setMaxTotal(100);
        poolConfig.setMaxIdle(100);
        poolConfig.setMinIdle(50);
        JedisPool jedisPool = new JedisPool(poolConfig, "cdh-node", 16379, "test01", "test01");
        Jedis jedis = jedisPool.getResource();
        System.out.println(jedis.ping());
//
//        Map<String, Double> zaddMp = new HashMap<>();
//        zaddMp.put("z10", Double.valueOf(10));
//        zaddMp.put("z30", Double.valueOf(20));
//        zaddMp.put("z40", Double.valueOf(40));
//        zaddMp.put("z30", Double.valueOf(30));
//
//        jedis.zadd("zadd_jedis", zaddMp);
//

//        jedis.sadd("sadd_jedis", "s1", "s1", "s2");

//        jedis.rpush("rpsuh_jedis", "1", "1", "2");

        System.out.println(jedis.lrange("rpsuh_jedis", 0, -2));


        jedis.close();


        // Redis6开启多用户
        // 1 修改redis配置文件 redis.conf
        // 2 将aclfile注释去掉 如：aclfile /etc/redis/users.acl
        // 3 创建acl文件，如：mkdir /etc/redis/users.acl
        // 4 创建用户，如：ACL SETUSER test01 on ~* &* +@all >test01
        // 5 保存用户信息到配置文件：acl save
    }
}
